package com.xuecheng.content.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xuecheng.content.mapper.CourseMarketMapper;
import com.xuecheng.content.model.po.CourseMarket;
import com.xuecheng.content.service.CourseMarketService;
import org.springframework.stereotype.Service;

/**
 * create 2023/5/6 20:14
 */
@Service
public class CourseMarketServiceImpl  extends ServiceImpl<CourseMarketMapper, CourseMarket> implements CourseMarketService {
    @Override
    public Integer saveOrUpdateCourseMarket(CourseMarket courseMarket) {

        String charge = courseMarket.getCharge();
        if(charge.equals("201001")){//收费
            if(courseMarket.getPrice() == null || courseMarket.getPrice().floatValue()<=0){
                throw new RuntimeException("课程为收费但是价格为空");
            }
        }
        boolean flag = this.saveOrUpdate(courseMarket);
        return flag?1:0;

    }
}
